<?php
namespace App\Utils\Other\Safepay\Payment;

use App\Utils\Other\Safepay\App;
use function Hyperf\Config\config;

/**
 * Class Mini
 * @author zx
 * @package App\Utils\Other\Safepay\Payment
 */
Class Mini extends App {

    public function __construct()
    {
        parent::__construct();
        $this->setConfig(['notify' => getDomain()."/publics/v1/payment/notify/safepayMini"]);
        $this->setConfig(['appid' => config('cloud.mini.app_id')]);
    }

    /**
     * 付款
     * @param array $params
     * @return array [$request, $response, $params]
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public function handle(array $params, string $appId=''):array
    {
        if ($appId) {
            $this->setConfig(['appid' => $appId]);
        }
        $params = $this->getParams($params);
        $this->setPath('unified');
        return $this->request($params);
    }
}